package activity_login;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.a17376009_wangzehui_finaltest.MainActivity;
import com.example.a17376009_wangzehui_finaltest.R;

public class Login extends AppCompatActivity {
    EditText username,password;
    Button  login;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login) ;
        username=(EditText) findViewById(R.id.editText1);
        password=(EditText) findViewById(R.id.editText2);
        login=(Button) findViewById(R.id.buttonHX);
        final String name=username.getText().toString();
        final String mima=password.getText().toString();
        login.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if(name.equals(" ")||mima.equals(" "))
                {
                    Toast.makeText(Login.this, "密码账号不能为空", Toast.LENGTH_SHORT).show();
                }
                else

                {
                    Intent intent=new Intent(Login.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }

            }
        });
    }
}
